import moment from "moment";
import util from "../../utils/apl-common";
Component({
  options: {
    addGlobalClass: true
  },
  /**
   * 组件接受的外部式样类
   */
  externalClasses: ["cutom-class"],
  /**
   * 组件的属性列表
   */
  properties: {
    orderData: {
      type: Object,
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    /**订单渲染数据 */
    orderDataNew: {},
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onDetail(e) {
      let orderDataset = e.currentTarget.dataset.order;
      var myEventDetail = {
        orderDataset,
      };
      var myEventOption = {};
      this.triggerEvent("orderDetail", myEventDetail, myEventOption);
    },
    /**
     * 设置订单数据
     * @param {*} item 订单数据源
     */
    setOrderData(item) {
      let orderDataNew = {};
      orderDataNew.id = item.serviceNeedNo;
      if (item.serviceCategory == "YS") {
        orderDataNew.title = `${item.serviceCategory_dictText} | ${item.serviceRank_dictText} ${item.serviceDays}${item.serviceUnit_dictText}`;
      } else {
        orderDataNew.title = `${item.serviceCategory_dictText} ${item.serviceDays}${item.serviceUnit_dictText}`;
      }
      if (item.interviewResult) {
        orderDataNew.statusText = item.interviewResult_dictText;
      } else if (item.interviewStatus) {
        orderDataNew.statusText = item.interviewStatus_dictText;
      } else if (item.recruitStatus) {
        orderDataNew.statusText = item.recruitStatus_dictText;
      }
      orderDataNew.adviserName = item.adviserName;
      orderDataNew.address = item.address
      orderDataNew.adviserTel = item.adviserTel;
      orderDataNew.interviewTime = moment(
        util.insertStr(item.interviewTime, 8, " ")
      ).format("YYYY-MM-DD hh:mm");
      this.setData({
        orderDataNew,
      });
    },
  },
  /**
   * 组件生命周期
   */
  lifetimes: {
    attached() {
      this.setOrderData(this.data.orderData);
    },
  },
});
